Plot basic things

This guide is organized as follows

In this guide we will focus on how-to plot things using AIBECS' built-in recipes for Plots.jl. These recipes are implemented using RecipesBase.jl, which are explained in Plots.jl's documentation.

Throughout we will use the OCIM1 grid and we will create a dummy tracer as a function of location to showcase each plot, just for the sake of the examples herein.

using AIBECS, Plots
grd, _ = OCIM1.load()
dummy = cosd.(latvec(grd))
200160-element Array{Float64,1}:
 0.3221204417984906 
 0.3546048870425357 
 0.38666674294141884
 0.41826780077556525
 0.44937040096716135
 0.4799374779597864 
 0.5099326043901359 
 0.5393200344991993 
 0.5680647467311559 
 0.5961324854692254 
 ⋮                  
 0.8854560256532099 
 0.8688879687250066 
 0.9154080085253663 
 0.9009688679024191 
 0.8854560256532099 
 0.8688879687250066 
 0.9154080085253663 
 0.9009688679024191 
 0.8854560256532099 

Horizontal plots

Horizontal slice

The most common thing you plot after a simulation of marine tracers is a horizontal slice. In this case, you just need to provide the tracer (dummy here), the grid object grd, and the depth at which you want to plot.

horizontalslice(dummy, grd, 10)
50 100 150 200 250 300 350 -60 -30 0 30 60 Longitude Latitude 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

You can supply units for the depth at which you want to see the horizontal slice.

horizontalslice(dummy, grd, 10u"m")
50 100 150 200 250 300 350 -60 -30 0 30 60 Longitude Latitude 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

And the units should be understood under the hood.

horizontalslice(dummy, grd, 3u"km")
50 100 150 200 250 300 350 -60 -30 0 30 60 Longitude Latitude 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

If your tracer is supplied with units, those will show in the colorbar label

horizontalslice(dummy * u"mol/m^3", grd, 10u"m")
50 100 150 200 250 300 350 -60 -30 0 30 60 Longitude Latitude 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 mol m^-3

The advantage of Plots.jl recipes like this one is that you can specify other pieces of the plot as you would with built-in functions. The advantage of Plots.jl recipes like this one is that you can specify other pieces of the plot as you would with built-in functions. For example, you can chose the colormap with the color keyword argument.

dummy .*= cosd.(lonvec(grd))
plt = horizontalslice(dummy, grd, 100, color=:balance)
50 100 150 200 250 300 350 -60 -30 0 30 60 Longitude Latitude - 0.75 - 0.50 - 0.25 0 0.25 0.50 0.75

And you can finetune attributes after the plot is created.

plot!(plt, xlabel="Lon", ylabel="Lat", colorbar_title="No units", title="The pacific as a whole")
50 100 150 200 250 300 350 -60 -30 0 30 60 The pacific as a whole Lon Lat - 0.75 - 0.50 - 0.25 0 0.25 0.50 0.75 No units

Vertical plots

Exploring the vertical distribution of tracers is important after all.

Zonal slices

You must specify the longitude

dummy .= cosd.(latvec(grd))
dummy .+= sqrt.(depthvec(grd)) / 30
zonalslice(dummy, grd, 330)
-60 -30 0 30 60 18 55 94 137 187 247 317 401 501 619 758 919 1104 1317 1559 1833 2141 2485 2867 3290 3756 4267 4825 5433 Latitude Depth (m) 0.5 1.0 1.5 2.0 2.5 3.0

Zonal averages

Global zonal average

zonalaverage(dummy, grd)
-60 -30 0 30 60 18 55 94 137 187 247 317 401 501 619 758 919 1104 1317 1559 1833 2141 2485 2867 3290 3756 4267 4825 5433 Latitude Depth (m) 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00

If you want a zonal average over a specific region, you can just mask it out

Basin zonal average

This is experimental at this stage and relies on an unregistered package OceanBasins. This part of the documentation will be online when OceanBasins gets registered.

You can create basin masks using this package with

using OceanBasins
mPAC = ispacific(grd)[iwet]
surfacemap(mPAC, grd, seriestype=:heatmap, color=:lightrainbow)
zonalaverage(dummy, grd, mask=mPAC)

Meridional slices

Just as you should expect at this stage, you can plot a meridional slice with

meridionalslice(dummy, grd, -30)
50 100 150 200 250 300 350 18 55 94 137 187 247 317 401 501 619 758 919 1104 1317 1559 1833 2141 2485 2867 3290 3756 4267 4825 5433 Longitude Depth (m) 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00

Depth profiles

Sometimes you want a profile at a given station or location

interpolateddepthprofile(dummy, grd, 0, 330)
1.5 2.0 2.5 3.0 18.0m 55.0m 94.0m 137.0m 187.0m 247.0m 317.0m 401.0m 501.0m 619.0m 758.0m 919.0m 1104.0m 1317.0m 1559.0m 1833.0m 2141.0m 2485.0m 2867.0m 3290.0m 3756.0m 4267.0m 4825.0m 5433.0m tracer depth y1

This page was generated using Literate.jl.